<template>
  <el-form ref="scriptForm" label-width="80px">

<!--    <el-form-item label="输入数据" prop="value1">-->
<!--      <el-input v-model="value1" :rows="10" type="textarea" placeholder="请输入内容"/>-->
<!--    </el-form-item>-->

    <el-form-item label="输入数据" prop="value1">
      <vue-json-editor v-model="value1" />
    </el-form-item>

    <el-form-item label="输出数据" prop="value2">
      <el-input v-model="value2" :rows="10" type="textarea" placeholder="请输入内容"/>
    </el-form-item>

    <el-form-item label="id" prop="id">
      <el-input v-model="id" :rows="2" type="textarea" placeholder="请输入内容"/>
    </el-form-item>

    <div>
      <el-button type="primary" @click="execute">测 试</el-button>
      <el-button type="primary" @click="getData">获取数据</el-button>
    </div>

  </el-form>
</template>

<script>
  import { execute, circuitGeneration, getCircuitData } from "@/api/expert/circuitType";
  import vueJsonEditor from 'vue-json-editor'
  export default {
    name: "test",
    components:{vueJsonEditor},
    data() {
      return {
        // 属性列表
        attributeList: [],
        // 属性模板列表
        attributeTemplateList: [],
        // 电路信息
        circuitData: {},
        // 枚举类型
        dataTypeEnum: this.GlobalVariable.dataTypeEnum,
        // 数据类型
        dataType: '',

        value1:{
          "bus":{"code":"USB","name":"数据总线接口类型（处理器接口）"},
          "volt":{"code":48,"name":"供电电压（电源输入电压）"},
          "analoguenum":{"code":1,"name":"模拟采样通道数量"},
          "digitalnum":{"code":1,"name":"数字采样通道数量"},
          "controller":{"code":"MCU","name":"处理器类型"},
          "prior":{"code":"balance","name":"设计考虑"},
          "qualitygrade":{"code":"Industrial","name":"质量等级"},
          "power":{"code":3,"name":"最大功率（电源最大功率）"},
          "analogue":[{
            "analogueno":{"code":1,"name":"第一通道"},
            "analoguename":{"code":"v1","name":"通道名称"},
            "analoguetype":{"code":1,"name":"通道采集类型（电压：1、温度：4）"},
            "sample":{"code":10,"name":"采样率"},
            "signalmax":{"code":20,"name":"最高频率"},
            "signalmin":{"code":10,"name":"最低频率"},
            "maxdatarange":{"code":20,"name":"最大输入"},
            "mindatarange":{"code":10,"name":"最小输入"},
            "samplingbit":{"code":8,"name":"采样精度"},
            "samplinglength":{"code":100,"name":"采样长度"}
          }],
          "digital":[{
            "digitalno":{"code":1,"name":"第一通道"},
            "digitalname":{"code":"d1","name":"通道名称"},
            "intype":{"code":"c","name":"源型"},
            "involt":{"code":5,"name":"信号电压"}
          }],
          "mainProjectId":'123'
        },
        value2:'',
        id:'',
      }
    },
    methods: {
      execute(){
        circuitGeneration({"param": JSON.stringify(this.value1)}).then(res =>{
          this.value2 = JSON.stringify(res.data)
        })
      },

      getData(){
        getCircuitData({"id": this.id}).then(res =>{
          this.value2 = JSON.stringify(res.data)
        })
      }


    }
  }
</script>

<style scoped>

</style>
